package 第二十章项目.clothesSystem.ShellOfBean;

import 第二十章项目.clothesSystem.bean.Clothes;

import java.util.ArrayList;
import java.util.List;

public class ShellofClothes {
    private String name;
    private double money;
    private int count;
    private String totalinfo;
    private List<Clothes> clotheslist=new ArrayList<>();

    public ShellofClothes() {
    }
    public ShellofClothes(String name,double money,int count,List<Clothes>clotheslist){};
    public ShellofClothes(String totalinfo) {
        this.totalinfo = totalinfo;
    }

    public String getTotalinfo() {
        return totalinfo;
    }

    public void setTotalinfo(String totalinfo) {
        this.totalinfo = totalinfo;
    }



    @Override
    public String toString() {
        if (name!=null){
        return "ShellofClothes{" +
                "name='" + name + '\'' +
                ", money=" + money +
                ", count=" + count +
                ", clotheslist=" + clotheslist +
                '}';
        }else{
            return "总计: ShellofClothes{ "+totalinfo+" }";
        }
    }
    public boolean getString(List<ShellofClothes> postlist){
        postlist.stream().map(ShellofClothes::getName)
                .forEach(System.out::println);
        return false;
    }

    public double getMoney() {

        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }
    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Clothes> getClotheslist() {
        return clotheslist;
    }

    public void setClotheslist(List<Clothes> clotheslist) {
        this.clotheslist = clotheslist;
    }

    public void addclothes_obj(Clothes clothes){
        clotheslist.add(clothes);
    }
    public int clotheslist_obj_count(){
        int count=clotheslist.size();
        return count;
    }
    public double clotheslist_obj_money(){
        final int size = clotheslist.size();
        double money = 0;
        //2选1 流式或则for式
        money=clotheslist.stream().mapToDouble(Clothes::getPrice).sum();
        String str_money=String.format("%.2f",money);
        money=Double.parseDouble(str_money);
        //for(int i=0;i<size;i++){
        //    money+=clotheslist.get(i).getPrice();
        //}
        return money;
    }


}
